<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/js/jquery.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/bootstrap.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/Font-Awesome-3.2.1/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/bootstrap.min.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/start/jquery.raty.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCss("CSS1","
    .cont_box img{
        height: 200px;
    }

   #loadings {
        left: 50%;
        position: absolute;
        top: 50%;
    }

");


?>
<style type="text/css">
    .main-box {

        height: 100%;
        left: 0;
        margin: 0 auto;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: -1;
    }
    .morcon {
        height: 100px;
        margin: 245px 20px 20px;
        position: relative;
        text-align: center;
    }
    .child_zw{
        cursor:pointer;
    }
    .morcon .reg {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        font-size: 20px;
        left: 4%;
        position: absolute;
        top: 0;
    }
    .morcon .login {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        display: block;
        font-size: 20px;
        left: 51%;
        position: absolute;
        top: 39%;
    }

    .wrap .header{
        width: 100%;
        position: relative;
        height: 300px;
    }
    .wrap .footer {
        height: 300px;
        position: relative;
        width: 100%;
    }

    .wrap .header .mydodo{
        background: url("<?php echo $this->staticsPath."/img/mydodo.png" ?>") no-repeat scroll 0 0 / 150px auto;
        height: 40px;
        width: 150px;
        position: absolute;
        right: 15px;
        top: 25px;
    }
    .wrap .header .imgbg{
        background: url("<?php echo $this->staticsPath."/img/imgbg.png" ?>") no-repeat scroll 0 0 / 150px auto;
        height: 150px;
        width: 150px;
        position: absolute;
        left: 15px;
        top: 90px;
    }
    .imgbg .box{
        width: 100%;
        height: 100%;
        position: relative;
    }
    .imgbg .box img {
        border-radius: 50%;
        height: 80%;
        left: 15px;
        position: absolute;
        top: 15px;
        width: 80%;
    }
    .wrap .header .hname {
        height: 200px;
        left: 170px;
        position: absolute;
        top: 144px;
        width: 200px;
    }
    .wrap .header .hname p{
        color: #0066b3;
        font-size: 20px;
    }
    .wrap .header .list {


        height: 80px;
        left: 25px;
        position: absolute;
        top: 25px;
        width: 80px;
    }
    .wrap .header .list a{
        color: #0066b3;
        font-size: 30px;
    }
    .wrap .footer .fbotton{
        width: 33%;
        height: 150px;
        float: left;
    }
    .wrap .footer .fbotton .like{
        background: url("<?php echo $this->staticsPath."/img/mylike.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .collection{
        background: url("<?php echo $this->staticsPath."/img/mycollection.png" ?>") no-repeat scroll 13px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .share{
        background: url("<?php echo $this->staticsPath."/img/share.png" ?>") no-repeat scroll -2px 15px / 114px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .point{
        background: url("<?php echo $this->staticsPath."/img/point.png" ?>") no-repeat scroll 6px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointlist{
        background: url("<?php echo $this->staticsPath."/img/pointlist.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointgift{
        background: url("<?php echo $this->staticsPath."/img/pointgift.png" ?>") no-repeat scroll 13px 11px / 90px auto;
        height: 100%;
        width: 100%;
    }
    body{
        background: #f4f4f4 none repeat scroll 0 0;
    }
    .topban{
        padding: 0 10px
    }
    .topban .top {
        color: #888;
        height: 20px;
        left: 50%;
        line-height: 20px;
        margin: -10px 0 52px -30px;
        position: absolute;
        top: 50%;
    }
    .topban .top.name {
        margin-top: -30px;
    }
    .topban .top.num {
        margin-top: -5px;
    }
    .topban .top.subject {
        margin-top: 20px;
    }
    #logout{
        color: #ffffff;
        font-size: 18px;
    }
    #logout:hover{
        color: #ffffff;
    }
    .lgt{
        width: 90%;
        height: 50px;
        text-align: center;
        margin: 20px auto 0 auto;
        margin-bottom: 50px;
        background: rgb(231,66,60);
        border-radius: 8px;
        line-height: 50px;
    }
    .right{
        float: right;
        margin-top: 10px;
    }
    .wrap .fa{
        width: 36px;
    }
    section a {
        color:#999
    }
    .modl_tel {
        background: #ffffff none repeat scroll 0 0;
        border-bottom: 1px solid #ccc;
        height: 60px;
        line-height: 60px;
        margin: 10px 0;
        padding-left: 10px;
    }
    .topban {
        padding: 0 10px;
    }
    .topban {
        background-color: #ffffff;
        overflow: hidden;
        position: relative;
        width: 100%;
    }
    .topban {
        background: #fff none repeat scroll 0 0;
        height: 140px;
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .status-people-pic {
        left: 0;
        margin-left: 15px;
        margin-top: -50px;
        position: absolute;
        top: 50%;
    }
    .stat-people {
        background: #fafafa none repeat scroll 0 0;
        border-radius: 30em;
        display: block;
        padding: 7px;
        position: relative;
        width: 100px;
    }
    .topban {
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .nav {
        background: rgb(249, 249, 249) none repeat scroll 0 0;
        border-top: 1px solid #ddd;
        bottom: 0;
        opacity: 0.9;
        padding: 6px 0 !important;
        position: fixed;
        width: 100%;
        height: 55px;
    }
    .nav .nav-box {
        color: #333;
        float: left;
        font-size: 14px;
        text-align: center;
        width: 33%;
        height: 100%;
    }
    .nav .nav-box.actt{
        color: #068043;
    }
    .nav .nav-box {
        color: #333;
        float: left;
        font-size: 14px;
        height: 100%;
        text-align: center;
        width: 49%;
    }
    .topban {
        overflow: unset;
        padding: 20px;
        position: relative;
        width: 100%;
    }
    .btn_footer a{
        color:#ffffff;
    }
    .lgt.ok{
        width: 90%;
        height: 50px;
        text-align: center;
        margin: 20px auto 0 auto;
        margin-bottom: 50px;
        background: #068043;
        border-radius: 8px;
        line-height: 50px;
    }
    #sign{
        color: #ffffff;
        font-size: 18px;
    }
    .wrap{
        padding: 0 20px;
    }
    #box1 table img{
        width: 20px;
    }
</style>

<div class="data">
    <header class="homeHder header">


        <?php if($aaa){ ?>
            <?php
            $Crole = Yii::app()->request->getParam('Crole');
            if($Crole){
            ?>
                <?php if(in_array("tk", $aaa)){ ?>
                <a style="width: 100px" id="refresh" href="javascript:void(0);">
                    <div style="cursor: pointer;margin-left: 10px;" class="hder_return flol">
                        <i class="fa fa-refresh" aria-hidden="true" style="font-size: 22px; margin-right: 5px;"></i>切换
                    </div>
                </a>
                <script type="text/javascript">
                    $(function(){
                        $("#refresh").click(function(){
                            if(window.confirm('你确定要切换成观察者吗？')){
                                window.location.href="<?php echo $this->createUrl('show',array('id'=>$id,'openid'=>$openid)) ?>";
                            }
                        })
                    });
                </script>
            <?php } ?>

            <?php }else{ ?>
                <?php if(in_array("tk", $aaa)){ ?>
                    <a style="width: 100px" id="refresh" href="javascript:void(0);">
                        <div style="cursor: pointer;margin-left: 10px;" class="hder_return flol">
                            <i class="fa fa-refresh" aria-hidden="true" style="font-size: 22px; margin-right: 5px;"></i>切换
                        </div>
                    </a>
                    <script type="text/javascript">
                        $(function(){
                            $("#refresh").click(function(){
                                if(window.confirm('你确定要切换成听课老师吗？')){
                                    window.location.href="<?php echo $this->createUrl('show',array('id'=>$id,'openid'=>$openid,'Crole'=>1)) ?>";
                                }
                            })
                        });
                    </script>
                <?php } ?>

            <?php } ?>
        <?php } ?>





        <div class="hder_logo">课程观测</div>
        <div class="hder_urse flor"><a  id="logOut"  href="javascript:void(0);"><i class="fa fa-sign-out"></i></a></div>
        <script type="text/javascript">
            $(function(){
                $("#logOut").click(function(){
                    if(window.confirm('你确定要退出吗？')){
                        $.ajax({
                            type: "POST",
                            url: '<?php echo Yii::app()->createUrl('observation/logOut') ?>',
                            data: {
                                'openid':'<?php echo $openid ?>'
                            },
                            dataType: "json",
                            success: function (data) {
                                if (data) {
                                    if(data.status==1){
                                        window.location.reload();
                                    }else{
                                        alert(data.message);
                                        return false;
                                    }
                                }else{
                                    alert('操作失败');
                                    return false;
                                }
                            }
                        });
                    }
                });
            });
        </script>
    </header>
    <div class="body_box" id="box1"  >
    <section class="wrap">
        <h3>评价指标</h3>
        <?php foreach($openPoint as $v){ ?>
        <div class="alert alert-info" role="alert"><?php echo $v->title ?></div>
            <?php $point_info = OpenPoint::model()->findAll('pid=:pid',array(':pid'=>$v->id)); ?>
        <table class="table table-striped">
            <tbody>

            <?php if($point_info){ ?>
            <?php foreach($point_info as $vv){ ?>
            <tr>
                <th style="width:180px;"><?php echo $vv->title ?></th>
                <td><div  id="star<?php echo $vv->id; ?>"></div></td>
            </tr>
                <?php } ?>
            <?php } ?>

            </tbody>
        </table>
        <?php } ?>

        <h3>评论</h3>
        <textarea class="form-control" id="comment" <?php if($commentInfo){ ?>disabled="disabled"<?php } ?> style="margin-top: 30px;height: 200px;" rows="3"><?php if($commentInfo){ ?><?php echo $commentInfo->text ?><?php }else{ ?>请输入您的听课建议<?php } ?></textarea>



        <?php if(!$startInfo){ ?>
            <div class="btn_footer">
                <a  href="javascript:void(0);"><div id="start_open" style="width: 100%" class="lgt ok">提交</div></a>
                <div class="clearfix"></div>
            </div>
        <?php } ?>



        <script type="text/javascript">
            $(function () {
                $(".nav-box").click(function(){
                    var kid = $(this).attr("data-type");
                    if(kid==3){
                        checlOpen('3');
                    }else{
                        $(".nav-box").removeClass('actt');
                        $(this).addClass("actt");

                        $(".body_box").hide();
                        $("#box"+kid).show();
                    }

                });
                function checlOpen(type){
                    $.ajax({
                        type: "POST",
                        url: '<?php echo $this->createUrl('ajaxCheckOpen'); ?>',
                        data: {
                            oid:'<?php echo $open_info->id ?>'
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data) {
                                if(data.status==1){
                                    Xalert('课程还没有结束无法查看统计');
                                    return false;

                                }else if(data.status==2){
                                    window.location.href="<?php echo $this->createUrl('accounting',array('id'=>$open_info->id,'openid'=>$openid)); ?>";
                                    return false;
                                }
                                else{
                                    Xalert('课程还没有结束无法查看统计');
                                    return false;
                                }
                            }else{
                                Xalert('操作失败');
                                return false;
                            }
                        }
                    });
                }
                $("#Ok").click(function(){
                    $("#myModal").modal('hide');
                    submitAjax();
                });
                $("#start_open").click(function(){
                    <?php if($allChildPoint){ ?>
                    <?php foreach($allChildPoint as $vvvv){ ?>
                    var c<?php echo $vvvv->id ?> =  $("#star<?php echo $vvvv->id ?> input").val();
                    if(c<?php echo $vvvv->id ?>==''){
                        $("#myModal").modal();
                        return false;
                    }
                    <?php } ?>
                    <?php } ?>
                    submitAjax();
                });


                $("#comment").focus(function(){
                    var comment = $("#comment").val();
                    if(comment=='请输入您的听课建议'){
                        $("#comment").val("");
                    }
                });
                function submitAjax(){
                    var comment = $("#comment").val();

                    if(comment=='请输入您的听课建议'){
                        Xalert('请输入您的听课建议');
                        return false;
                    }
                    if (comment.length == 0 || comment.length < 30) {
                        Xalert('评语不能为空或小于30个字符限制');
                        return false;
                    };
                    <?php if($allChildPoint){ ?>
                    <?php foreach($allChildPoint as $vvvv){ ?>
                    var c<?php echo $vvvv->id ?> =  $("#star<?php echo $vvvv->id ?> input").val();
                    <?php } ?>
                    <?php } ?>
                    $.ajax({
                        type: "POST",
                        url: '<?php echo $this->createUrl('ajaxSendComment'); ?>',
                        data: {
                            comment:comment,
                            oid:'<?php echo $open_info->id ?>',
                            openid:'<?php echo $openid ?>',
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data) {
                                if(data.status==1){
                                    Xalert(data.message);
                                    lock = true;
                                    $("#comment").text(comment);
                                    $("#comment").attr("disabled","disabled");

                                    $("#send_commend").hide();
                                }else{
                                    Xalert(data.message);
                                    return false;
                                }
                            }else{
                                Xalert('操作失败');
                                return false;
                            }
                        }
                    });
                    $.ajax({
                        type: "POST",
                        url: '<?php echo $this->createUrl('ajaxSendStart'); ?>',
                        data: {
                            <?php if($allChildPoint){ ?>
                            <?php foreach($allChildPoint as $vc){ ?>
                            <?php echo $vc->id ?>:c<?php echo $vc->id ?>,
                            <?php } ?>
                            <?php } ?>
                            oid:'<?php echo $open_info->id ?>',
                            openid:'<?php echo $openid ?>',
                        },
                            dataType: "json",
                                success: function (data) {
                                if (data) {
                                    if(data.status==1){
                                        Xalert(data.message);
                                        setTimeout(function(){
                                            window.location.reload();
                                        },2000)
                                    }else{
                                        Xalert(data.message);
                                        return false;
                                    }
                                }else{
                                    Xalert('操作失败');
                                    return false;
                                }
                            }
                        });
                }

            })
        </script>

        <div style="width:100%;height: 80px"></div>
    </section>
    </div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" >确认提交？</h4>
                </div>
                <div class="modal-body">
                    你有评价未评分，确认提交么？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" id="Ok" class="btn btn-primary">确认</button>
                </div>
            </div>
        </div>
    </div>



    <div class="body_box" id="box2" style="display: none" >
        <section class="wrap">



        </section>
    </div>
    <script type="text/javascript">
        var lock = false;
        $(function () {
            if(lock==false){

            }

            $("#send_commend").click(function(){

            });
        })
    </script>
    <nav class="nav">
        <a href="javascript:void(0);" class="">
            <div  data-type="1" class="nav-box actt">
                <i class="fa fa-book"></i>评价
            </div>
        </a>
        <a  href="javascript:void(0);" class="">
            <div  data-type="3" class="nav-box">
                <i class="fa fa-home"></i>统计
            </div>
        </a>
    </nav>

</div>
<div class="modal fade" id="Xalert" data-id="1" tabindex="-1" role="dialog" aria-labelledby="linkModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <!-- 登陆页面注册提示 -->
        <div class="modal-content text-left">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">提示</h4>
            </div>
            <div class="modal-body">
                <p id="alertMassage"></p>
                <button type="button" style="margin-top: 20px" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function Xalert(html){
        $("#alertMassage").html(html);
        $("#Xalert").modal();
        setTimeout(function(){$("#Xalert").modal('hide')},2000);
    }
    $(function(){
        <?php if($startInfo){ ?>
        <?php if($allChildPoint){ ?>
        <?php foreach($allChildPoint as $vvv){ ?>
        <?php $lll = $vvv->id ?>
        $('#star<?php echo $vvv->id ?>').raty({
            readOnly: true,
            size:24,
            score: <?php echo $startInfo[$lll]; ?>,
            iconRange: [
                { range: 1, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 2, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 3, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 4, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 5, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' }
            ]
        });
        <?php } ?>
        <?php } ?>
        <?php }else{ ?>
        <?php if($allChildPoint){ ?>
        <?php foreach($allChildPoint as $vvv){ ?>
        $('#star<?php echo $vvv->id ?>').raty({
            size:24,
            iconRange: [
                { range: 1, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 2, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 3, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 4, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' },
                { range: 5, on: '<?php echo $this->staticsPath."/start/img/star-on.png" ?>', off: '<?php echo $this->staticsPath."/start/img/star-off.png" ?>' }
            ]
        });
        <?php } ?>
        <?php } ?>
        <?php } ?>

    });
</script>
